// hyb_yl/mysubpages/pages/search/search.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    searchCont: "",
    searchtype:[
      { picimg: "../../../images/yisheng.png", names: "医生" },
      { picimg: "../../../images/yiyuan.png", names: "医院" },
      { picimg:"../../../images/yiyaopin.png",names:"药品"},
    ],
    searchArr: [],
    findArr: [
      { huo: true, text: "dfsad" },
      { huo: false, text: "京东方回到家" },
      { huo: false, text:"大家"},
    ],
    searchlist: ["列表一", "列表二", "列表三", "列表四", "列表五", "列表六"],
  },
  // 搜索类型
  typesbtn(e){
    if(e.currentTarget.dataset.dex == "0"){
      wx.navigateTo({
        url: '../searchyisheng/searchyisheng',
      })
    } else if (e.currentTarget.dataset.dex == "1"){
      wx.navigateTo({
        url: '../searchyiyuan/searchyiyuan',
      })
    } else if (e.currentTarget.dataset.dex == "2") {
      wx.navigateTo({
        url: '../searchyaopin/searchyaopin',
      })
    }
  }, 
  getSearch: function (e) {
    this.setData({
      searchCont: e.detail.value
    })
  },
  del: function () {
    var searchArr = this.data.searchArr;
    this.setData({
      searchArr: [],
      searchCont:""
    })
    wx.setStorage({
      key: 'searchArr',
      data: this.data.searchArr,
    })
  },
  searchHistory:function(e){
    console.log(e)
    this.setData({
      searchCont: e.currentTarget.dataset.item
    })
    this.sou()
  },
 
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var searchArr = wx.getStorageSync("searchArr") || []
    this.setData({
      searchArr:searchArr
    })
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})